Skip to content

feat: read gathering lines from dedicated table - #4721

Draft
turip wants to merge 4 commits into
mainfrom
feat/migrate-gathering-invoice-lines
Draft

feat: read gathering lines from dedicated table#4721
turip wants to merge 4 commits into
mainfrom
feat/migrate-gathering-invoice-lines

Conversation

@turip

@turip turip commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

  • make gathering-line DB state record whether a line came from billing_invoice_lines or billing_gathering_invoice_lines
  • read and merge gathering lines from both tables while rejecting duplicate IDs
  • keep standard-line and gathering-line subscription reads behind their respective adapter and service contracts
  • update subscription sync to load both standard persisted state and gathering leaves
  • expand split-line hierarchy mapping across both line tables
  • keep dedicated-table writes disabled during this read-compatible migration stage

Stack

Depends on #4720, which introduces the dedicated gathering invoice line schema.

Impact

This is the first migration iteration: existing gathering lines remain writable through the legacy table, while lines already migrated to the dedicated table become readable by billing and subscription sync. Conflicting rows in both tables fail explicitly instead of being resolved implicitly.

Validation

  • make test-nocache

Greptile Summary

This PR adds read compatibility for gathering lines stored in either invoice-line table. The main changes are:

  • Records the source table in each gathering line snapshot.
  • Reads and merges legacy and dedicated gathering lines.
  • Rejects duplicate line IDs across the two tables.
  • Splits standard and gathering subscription reads.
  • Loads split-line hierarchies from both tables.
  • Keeps dedicated-table writes disabled during migration.

Confidence Score: 5/5

This looks safe to merge.

  • Split-group members are excluded from standalone gathering reads and remain available through their hierarchy.
  • Both subscription reads retain the transaction-bearing lock context.
  • No blocking issue remains in the updated code.

Important Files Changed

Filename Overview
openmeter/billing/adapter/gatheringlines.go Adds dual-table gathering-line reads, source-aware snapshots, duplicate checks, and split-group filtering.
openmeter/billing/adapter/invoicelinesplitgroup.go Extends split-line hierarchy mapping to dedicated gathering lines.
openmeter/billing/adapter/stdinvoicelines.go Separates standard subscription reads while retaining split-line hierarchy loading.
openmeter/billing/worker/subscriptionsync/service/persistedstate/loader.go Combines standard persisted state with standalone gathering leaves.

Reviews (3): Last reviewed commit: "fix: exclude split gathering lines from ..." | Re-trigger Greptile

Context used (3)

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)
  • Context used - api/spec/AGENTS.md (source)

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b462ee7-5794-4e6e-8521-a24d13504645

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/migrate-gathering-invoice-lines

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@turip turip added area/billing kind/feature New feature or request release-note/feature Release note: Exciting New Features labels Jul 16, 2026
@turip
turip force-pushed the feat/gathering-invoice-line-schema branch from 512a0d5 to d743881 Compare July 16, 2026 08:56
Comment thread openmeter/billing/adapter/gatheringlines.go
@turip
turip force-pushed the feat/gathering-invoice-line-schema branch from d743881 to 1a36de3 Compare July 16, 2026 09:26
@turip
turip force-pushed the feat/gathering-invoice-line-schema branch from 1a36de3 to d2fc9da Compare July 16, 2026 10:41
@turip
turip force-pushed the feat/migrate-gathering-invoice-lines branch from d6b00e2 to 0fdf6ca Compare July 16, 2026 10:43
Base automatically changed from feat/gathering-invoice-line-schema to main July 16, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing kind/feature New feature or request release-note/feature Release note: Exciting New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant